/*
XPTracker - Alternative Agile Tracking Tool
Copyright (C) 2006-2009  Stephen Starkey

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
*/
package org.xptracker.persistence;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class FakePersistenceManager implements PersistenceManager {
  private Log log = LogFactory.getLog(getClass());

  public String getDbType() {
    return "fake";
  }

  public void initialize(DomainRegistry domainRegistry) {
  }

  public void shutdown() {
  }

  public void doMaintenance() {
  }

  public <T> T inTransaction(UpdateHandler<T> handler) {
    return handler.doUpdate(new UpdateReceiver() {
      public void insert(Object o) {
        log.info("Insert: " + o);
      }

      public void update(Object o) {
        log.info("Update: " + o);
      }

      public void remove(Object o) {
        log.info("Remove: " + o);
      }
    });
  }

  public <T> List<T> query(String query) {
    log.info("Query: " + query);
    return Collections.emptyList();
  }

  public <T> List<T> query(String query, Map<String, Object> args) {
    log.info("Query: " + query + ", args: " + args);
    return Collections.emptyList();
  }

  public <T> List<T> queryWithScript(String query, Object... args) {
    return null;
  }

  public void flush() {
    //noop
  }

  public <T extends Identified> List<T> listObjects(Class<T> objectClass, Set<String> ids) {
    return null;
  }

  public <T> T loadObject(Class<? extends T> entityType, String id) {
    return null;
  }

  public <T> T loadObject(Class<? extends T> entityType, String id, FetchHelper<T> helper) {
    throw new UnsupportedOperationException();
  }
}
